#include "Source/Core/Vector.h"

Vector::Vector(float newX, float newY, float newZ):
x(newX),
y(newY),
z(newZ)
{
}


Vector Vector::operator-()
{
	Vector result;
	result.x = -x;
	result.y = -y;
	result.z = -z;

	return result;

}

Vector Vector::operator=(const Vector & rhs)
{
	if(this!=&rhs)
	{
	x = -rhs.x;
	y = -rhs.y;
	z = -rhs.z;
	}
	return *this;

}

Vector Vector::operator+(const Vector & rhs)
{
	Vector result;
	result.x = x + rhs.x;
	result.y = y + rhs.y;
	result.z = z + rhs.z;
	return result;
}

Vector Vector::operator-(const Vector & rhs)
{
	Vector result = -(*this);
	return result;
}

Vector Vector::operator*(const float & rhs)
{
	Vector result;
	result.x = x*rhs;
	result.y = y*rhs;
	result.z = z*rhs;
	return result;
}

Vector Vector::operator/(const float & rhs)
{
	if(rhs!=0)
	return *this*(1.0f/rhs);
}

float Vector::dotProduct(const Vector & lhs, const Vector & rhs)
{
	float result = lhs.x*rhs.x+lhs.y*rhs.y+lhs.z*rhs.z;
	return result;
}

Vector Vector::crossProduct(const Vector & lhs, const Vector & rhs)
{
	Vector result;
	result.x = lhs.y*rhs.z - lhs.z*rhs.y;
	result.y = lhs.z*rhs.x - lhs.x*rhs.z;
	result.z = lhs.x*rhs.y - lhs.y*rhs.x;
	return result;
}